table.insert(itemActions,
   function(item, action)
      -- UNIQUE charms
      if not (item.quality == ItemQuality.Unique and
            (item.baseItem.code == "cm1" or
            item.baseItem.code == "cm2" or
            item.baseItem.code == "cm3")) then
         return false
      end

      return processItemList(item, action, uniqueCharms)
   end
)


--[[


Due to AO's limitations, namely the "Pickit missed item" infinite retry pick loop,
ONLY enable unique\charms.lua in your includes.lua when you DO NOT have a Gheeds!
If you DO have a Gheeds, and have this file enabled when one drops, you will get stuck in a picking loop!


]]--



-- see: dir .. "readme.txt" for information regarding itemLists

uniqueCharms = {
   --{"cm1", 9, false}, -- Annihilus
   --{"cm2", 9, false}, -- Hellfire Torch
   
   
   {"cm3", 7, true, -- Gheed's Fortune
      function(item)
         if item.action ~= ItemActionType.DropToGround then -- we don't have one already
            if item.flags.Identified then
               return isGoodGheeds(item)
            elseif not item.flags.Identified then
               return true -- unid
            end
         else
            return false -- we already have one
         end
      end
   }
}

function isGoodGheeds(item)
   local mf, gf, rvp = 0, 0, 0
   
   for i = 0, item.mods:size() - 1 do
      if item.mods[i].Stat.Type == StatType.GoldFind then
         gf = item.mods[i].Value
      elseif item.mods[i].Stat.Type == StatType.MagicFind then
         mf = item.mods[i].Value
      elseif item.mods[i].Stat.Type == StatType.ReducedPrices then
         rvp = item.mods[i].Value
      end
   end
   
   return (mf >= 39) and ((gf >= 150) or (rvp >= 14)) -- 39-40 mf and (150-perf gold or 14-perf vendor)
end
